package iset.coverageanalyzer.config;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Properties;

public class ConfigTool {
	
	public static ConfigInfo loadConfig(String configPath){
		ConfigInfo ci = new ConfigInfo();
		
		InputStreamReader isReader = null;
		try {
			isReader = new InputStreamReader(new FileInputStream(configPath));
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
			return null;
		}
		
		Properties p = new Properties();
		try {
			p.load(isReader);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
		}
		
		ci.inputJava = p.getProperty("input.java");
		ci.inputXML = p.getProperty("input.xml");
		ci.outputJava = p.getProperty("output.java");
		ci.outputJPF = p.getProperty("output.jpf");
		
		return ci;
	}
	
	// for testing
	public static void main(String[] args){
		ConfigInfo ci = loadConfig("config.properties");
		System.out.println("Input xml : "+ci.inputXML);
		System.out.println("Input java : "+ci.inputJava);
		System.out.println("Output jpf : "+ci.outputJPF);
		System.out.println("Output java : "+ci.outputJava);
	}
	
}
